package edu.towson.cosc603.coffeemaker;

import static org.junit.Assert.*;
import junit.framework.TestCase;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

public class InventoryTest extends TestCase{
	Inventory inv;
	Recipe	r1;

	@Before
	public void setUp() throws Exception {
		inv = new Inventory();
		r1 = new Recipe();
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testInventory() {
		Assert.assertEquals(inv, inv);
	}

	@Test
	public void testGetChocolate() {
		inv.setChocolate(8);
		Assert.assertEquals(8, inv.getChocolate());
	}

	@Test
	public void testSetChocolate() {
		inv.setChocolate(8);
		Assert.assertEquals(8, inv.getChocolate());
	}
	
	@Test
	public void testSetChocolateLessThanZero() {
		inv.setChocolate(-2);
		Assert.assertEquals(0, inv.getChocolate());
	}

	@Test
	public void testSetChocolateZero() {
		inv.setChocolate(0);
		Assert.assertEquals(0, inv.getChocolate());
	}
	
	@Test
	public void testGetCoffee() {
		inv.setCoffee(7);
		Assert.assertEquals(7, inv.getCoffee());
	}

	@Test
	public void testSetCoffee() {
		inv.setCoffee(7);
		Assert.assertEquals(7, inv.getCoffee());
	}
	
	@Test
	public void testSetCoffeeLessThanZero() {
		inv.setCoffee(-2);
		Assert.assertEquals(0, inv.getCoffee());
	}

	@Test
	public void testGetMilk() {
		inv.setMilk(6);
		Assert.assertEquals(6, inv.getMilk());
		
	}

	@Test
	public void testSetMilk() {
		inv.setMilk(6);
		Assert.assertEquals(6, inv.getMilk());
	}

	@Test
	public void testSetMilkLessThanZero() {
		inv.setMilk(-2);
		Assert.assertEquals(0, inv.getMilk());
	}
	
	@Test
	public void testGetSugar() {
		inv.setSugar(6);
		Assert.assertEquals(6, inv.getSugar());
	}

	@Test
	public void testSetSugar() {
		inv.setSugar(6);
		Assert.assertEquals(6, inv.getSugar());
	}

	@Test
	public void testSetSugarLessThanZero() {
		inv.setSugar(-2);
		Assert.assertEquals(0, inv.getSugar());
	}
	
	@Test
	public void testEnoughIngredients() {
		r1.setAmtChocolate(9);
		r1.setAmtCoffee(8);
		r1.setAmtMilk(7);
		r1.setAmtSugar(6);
		r1.setName("Hot Chocolate");
		r1.setPrice(3);
		
		inv.enoughIngredients(r1);
		
		Assert.assertTrue(true);
	}
	
	@Test
	public void testEnoughIngredientsCoffee() {
		r1.setAmtChocolate(9);
		r1.setAmtCoffee(20);
		r1.setAmtMilk(7);
		r1.setAmtSugar(6);
		r1.setName("Hot Chocolate");
		r1.setPrice(3);
		
		inv.enoughIngredients(r1);
		
		Assert.assertFalse(false);
	}
	
	@Test
	public void testEnoughIngredientsMilk() {
		r1.setAmtChocolate(9);
		r1.setAmtCoffee(10);
		r1.setAmtMilk(18);
		r1.setAmtSugar(6);
		r1.setName("Hot Chocolate");
		r1.setPrice(3);
		
		inv.enoughIngredients(r1);
		
		Assert.assertFalse(false);
	}
	
	@Test
	public void testEnoughIngredientsSugar() {
		r1.setAmtChocolate(9);
		r1.setAmtCoffee(10);
		r1.setAmtMilk(7);
		r1.setAmtSugar(19);
		r1.setName("Hot Chocolate");
		r1.setPrice(3);
		
		inv.enoughIngredients(r1);
		
		Assert.assertFalse(false);
	}
	
	@Test
	public void testEnoughIngredientsChocolate() {
		r1.setAmtChocolate(20);
		r1.setAmtCoffee(10);
		r1.setAmtMilk(7);
		r1.setAmtSugar(6);
		r1.setName("Hot Chocolate");
		r1.setPrice(3);
		
		inv.enoughIngredients(r1);
		
		Assert.assertFalse(false);
	}
	
	@Test
	public void testToString() {	
		String expected = "Coffee: " + 15 + "\n" +
				"Milk: " + 15 + "\n" +
				"Sugar: " + 15 + "\n" +
				"Chocolate: " + 15 + "\n";
		
		Assert.assertEquals(expected, inv.toString());
	}

}
